﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dapper;
using Models;
using Common;
using System.Data.SqlClient;
using System.Data;
using System.ComponentModel;

namespace DbControl
{
    public class OprSensordatas
    {
        public static int Insert(sensordatas data)
        {
            try
            {
                using (IDbConnection connection = new SqlConnection(OprSql.connectString))
                {
                    string sql = @"INSERT INTO sensordatas
                       (sensor_sn 
                       ,device_code 
                       ,device_name 
                       ,create_time 
                       ,temper 
                       ,dens 
                       ,vis 
                       ,vis40 
                       ,diel 
                       ,ppm 
                       ,aw 
                       ,mo 
                       ,par1 
                       ,par2 
                       ,par3 
                       ,par4 
                       ,par5 
                       ,par6 
                       ,par7 
                       ,par8 
                       ,class1 
                       ,class2 
                       ,class3 
                       ,class4 
                       ,class5 
                       ,class6 
                       ,class_total 
                       ,standard 
                       ,fe1 
                       ,fe2 
                       ,fe3 
                       ,fe4 
                       ,fe5 
                       ,fe6 
                       ,fe7 
                       ,fe8 
                       ,fe9 
                       ,fe10 
                       ,nfe1 
                       ,nfe2 
                       ,nfe3 
                       ,nfe4 
                       ,nfe5 
                       ,fe 
                       ,nfe 
                       ,state 
                       ,press 
                       ,speed 
                       ,buffer_temper)
                 VALUES
                       (@sensor_sn 
                       ,@device_code 
                       ,@device_name 
                       ,@create_time 
                       ,@temper 
                       ,@dens 
                       ,@vis 
                       ,@vis40 
                       ,@diel 
                       ,@ppm 
                       ,@aw 
                       ,@mo 
                       ,@par1 
                       ,@par2 
                       ,@par3 
                       ,@par4 
                       ,@par5 
                       ,@par6 
                       ,@par7 
                       ,@par8 
                       ,@class1 
                       ,@class2 
                       ,@class3 
                       ,@class4 
                       ,@class5 
                       ,@class6 
                       ,@class_total 
                       ,@standard 
                       ,@fe1 
                       ,@fe2 
                       ,@fe3 
                       ,@fe4 
                       ,@fe5 
                       ,@fe6 
                       ,@fe7 
                       ,@fe8 
                       ,@fe9 
                       ,@fe10 
                       ,@nfe1 
                       ,@nfe2 
                       ,@nfe3 
                       ,@nfe4 
                       ,@nfe5 
                       ,@fe 
                       ,@nfe 
                       ,@state 
                       ,@press 
                       ,@speed 
                       ,@buffer_temper)";
                    return connection.Execute(sql, data);
                }
            }
            catch (Exception ex)
            {
                lLogWrite.WriteLog(ex.ToString());
                return 0;
            }
        }
    }
}
